package com.house.user.controller;

import java.util.Arrays;
import java.util.Map;


import com.house.common.utils.PageUtils;
import com.house.common.utils.R;
import com.house.user.entity.SubscribeEntity;
import com.house.user.service.SubscribeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;




/**
 * 
 *
 * @author yangxinyu
 * @email yangxinyu03201@gmail.com
 * @date 2022-04-22 13:34:09
 */
@RestController
@RequestMapping("user/subscribe")
public class SubscribeController {
    @Autowired
    private SubscribeService subscribeService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = subscribeService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{fid}")
    public R info(@PathVariable("fid") Integer fid){
		SubscribeEntity subscribe = subscribeService.getById(fid);

        return R.ok().put("subscribe", subscribe);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody SubscribeEntity subscribe){
		subscribeService.save(subscribe);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody SubscribeEntity subscribe){
		subscribeService.updateById(subscribe);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] fids){
		subscribeService.removeByIds(Arrays.asList(fids));

        return R.ok();
    }

}
